
QuercusEngine
Copyright 2010 Stani Ryabenkiy

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.   


Parts of this software are derived from the Quercus JSR-223 Script Engine
implementation (com.caucho.quercus.script.QuercusScriptEngine), the license
for which is reproduced in the source file.

=====================================================================


QuercusEngine makes it possible to execute Quercus PHP scripts using 
the Bean Scripting Framework (BSF) 2.4 API. 


COMPILATION
===========

Compiling QuercusEngine requires numerous components on the classpath:

• The javax.script API, either included with Java 6 or BSF 3.0 or another
  implementation.

• The Servlet API, which Quercus itself depends on. Version 2.5 was used.

• The Resin libraries, since Quercus depends on the VFS system from Resin.
  Resin can be obtained from http://www.caucho.com/.

• The BSF libraries. Version 2.4 was used.

The included Apache Ant build script can be used to compile QuercusEngine 
and create a Jar file suitable for deployment. The build script is targeted
at Java 1.4 but must be modified to point to the locations of the Resin,
servlet, BSF and javax.script Jar files. 


DEPLOYMENT
==========

To deploy QuercusEngine, the following steps are necessary:

• Make the QuercusEngine class available to your application.

• Place BSF 2.4 on the application's classpath.

• org.apache.bsf.BSFManager depends on Apache Commons Logging, so the Commons
  Logging package must also be made available to the application. Commons
  Logging can be obtained from http://commons.apache.org/logging/. 

• The javax.script API must be available, either from Java 6, from BSF 3.0,
  or from another source.

• The application also needs access to the Servlet API. Version 2.5 was tested.

• The Resin libraries should also be placed on the classpath.


USAGE
=====

Using the QuercusEngine is identical to using any other custom BSF engine. 
After registering the engine class, it can be used to evaluate scripts. 

Example usage:

String script = " <?php \n Print \"Hello, World!\"; \n ?> "; 
	
BSFManager.registerScriptingEngine("php", "org.apache.bsf.engines.quercus.QuercusEngine", null); 	
BSFManager bsf = new BSFManager();
BSFEngine engine = bsf.loadScriptingEngine("php"); 	

engine.eval("<unknown>", 0, 0, script );

